package com.mall.service;

import com.mall.autoconfig.temple.OssTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

@Service
public class AliyunService {
    @Autowired
    private OssTemplate ossTemplate;
    public Map upload(MultipartFile photoFile) throws IOException {
        //将图片上传到阿里云
        String imageUrl = ossTemplate.upload(photoFile.getOriginalFilename(), photoFile.getInputStream());
        Map<String,String>map=new HashMap<>();
        map.put("url",imageUrl);
        return map;
    }
}
